home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / dvivga9.zip / FILLRECT.H < prev    next >
Text File  |  1988-05-30  |  2KB  |  53 lines

  1. /* -*-C-*- fillrect.h */
  2. /*-->fillrect*/
  3. /**********************************************************************/
  4. /****************************** fillrect ******************************/
  5. /**********************************************************************/
  6.  
  7. void
  8. fillrect(x,y,width,height)
  9. COORDINATE x,y,width,height;        /* lower left corner, size */
  10.  
  11. /***********************************************************************
  12. With the page origin (0,0) at the lower-left corner of the bitmap,  draw
  13. a filled rectangle at (x,y).
  14. ***********************************************************************/
  15.  
  16. {
  17.     register UNSIGN32 *p;
  18.     register COORDINATE i,j,xloffset,xroffset,xlpart,xrpart;
  19.  
  20.     if ( ((x+width) <= 0) || (XSIZE <= x) || ((y+height) <= 0) ||
  21.     (YSIZE <= y) )
  22.     return;        /* Trivial reject -- rectangle outside page */
  23.     else
  24.     {
  25.     xlpart = x/HOST_WORD_SIZE;
  26.     xrpart = (x + width)/HOST_WORD_SIZE;
  27.     xloffset = x % HOST_WORD_SIZE;
  28.     xroffset = (x + width) % HOST_WORD_SIZE;
  29.     for (j = 0; j < height; ++j)        /* loop over raster lines */
  30.     {
  31.         if (IN(0,y+j,YBIT-1))
  32.         {
  33.         p = BITMAP(y+j,xlpart);
  34.         if (IN(0,xlpart,XBIT-1))
  35.             if (xlpart < xrpart) /* set bits in left partial word */
  36.             *p |= rightones[xloffset];
  37.             else    /* set bits in middle of left partial word */
  38.             *p |= (rightones[xloffset] & ~rightones[xroffset]);
  39.  
  40.         ++p;
  41.         for (i = xlpart+1; i < xrpart; (++p,++i))
  42.             if (IN(0,i,XBIT-1))
  43.             *p = (UNSIGN32)ONES;  /* set complete words */
  44.  
  45.         /* finally, set bits in right partial word */
  46.         if ((xlpart < xrpart) && IN(0,xrpart,XBIT-1))
  47.             *BITMAP(y+j,xrpart) |= ~rightones[xroffset];
  48.         }
  49.     }
  50.     }
  51. }
  52.  
  53.